#pragma once

#include <ros/ros.h>
#include <pack_msg/CompositeData.h>
#include <pack_msg/StateChangeNotice.h>
#include <pack_msg/LiveSetting.h>
#include <string>
#include "live_config_types.h"

struct LiveSetting {
    std::string video_id;
    std::string url;
    int url_type;
    int video_quality;
    std::string video_type;
    int camera_position;
};


class LiveStreamingNode {
public:
    LiveStreamingNode(ros::NodeHandle &nh);
    void run();

private:
    void cloudMessageCallback(const pack_msg::CompositeData::ConstPtr &msg);
    bool loadOrUpdateConfig();
    bool notifyStateChange(int id);

    void startLive(const pack_msg::LiveSetting &setting);
    void stopLive(const pack_msg::LiveSetting &setting);

    ros::Subscriber message_sub_;
    ros::ServiceClient state_update_client_;

    std::string topic_name_;
    std::string update_service_name_;
    std::string config_file_path_ = "/config/uav_live.json";
    std::string _video_source;
    std::string _audio_source;
    int _latency;
    int _log_level;

    LiveCapacityConfig default_config_;
    LiveCapacityConfig current_config_;
    pack_msg::LiveSetting live_setting_;

};
